home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / patch20u.lha / patch-2.0.12u9 / common.h < prev    next >
C/C++ Source or Header  |  1993-05-29  |  5KB  |  199 lines

  1. /* $Header: common.h,v 2.0.1.2 88/06/22 20:44:53 lwall Locked $
  2.  *
  3.  * $Log:    common.h,v $
  4.  * Revision 2.0.1.2  88/06/22  20:44:53  lwall
  5.  * patch12: sprintf was declared wrong
  6.  * 
  7.  * Revision 2.0.1.1  88/06/03  15:01:56  lwall
  8.  * patch10: support for shorter extensions.
  9.  * 
  10.  * Revision 2.0  86/09/17  15:36:39  lwall
  11.  * Baseline for netwide release.
  12.  * 
  13.  */
  14.  
  15. #define DEBUGGING
  16.  
  17. #define VOIDUSED 7
  18. #include "config.h"
  19.  
  20. /* shut lint up about the following when return value ignored */
  21.  
  22. #define Signal (void)signal
  23. #define Unlink (void)unlink
  24. #define Lseek (void)lseek
  25. #define Fseek (void)fseek
  26. #define Fstat (void)fstat
  27. #define Pclose (void)pclose
  28. #define Close (void)close
  29. #define Fclose (void)fclose
  30. #define Fflush (void)fflush
  31. #define Sprintf (void)sprintf
  32. #define Mktemp (void)mktemp
  33. #define Strcpy (void)strcpy
  34. #define Strcat (void)strcat
  35.  
  36. /* NeXT declares malloc and realloc incompatibly from us in some of
  37.    these files.  Temporarily redefine them to prevent errors.  */
  38. #define malloc system_malloc
  39. #define realloc system_realloc
  40. #include <stdio.h>
  41. #include <assert.h>
  42. #include <sys/types.h>
  43. #include <sys/stat.h>
  44. #include <ctype.h>
  45. #include <signal.h>
  46. #undef malloc
  47. #undef realloc
  48.  
  49. /* constants */
  50.  
  51. /* AIX predefines these.  */
  52. #ifdef TRUE
  53. #undef TRUE
  54. #endif
  55. #ifdef FALSE
  56. #undef FALSE
  57. #endif
  58. #define TRUE (1)
  59. #define FALSE (0)
  60.  
  61. #define MAXHUNKSIZE 100000        /* is this enough lines? */
  62. #define INITHUNKMAX 125            /* initial dynamic allocation size */
  63. #define MAXLINELEN 1024
  64. #define BUFFERSIZE 1024
  65.  
  66. #define SCCSPREFIX "s."
  67. #define GET "get %s"
  68. #define GET_LOCKED "get -e %s"
  69. #define SCCSDIFF "get -p %s | diff - %s >/dev/null"
  70.  
  71. #define RCSSUFFIX ",v"
  72. #define CHECKOUT "co %s"
  73. #define CHECKOUT_LOCKED "co -l %s"
  74. #define RCSDIFF "rcsdiff %s > /dev/null"
  75.  
  76. #ifdef FLEXFILENAMES
  77. #define ORIGEXT ".orig"
  78. #define REJEXT ".rej"
  79. #else
  80. #define ORIGEXT "~"
  81. #define REJEXT "#"
  82. #endif
  83.  
  84. /* handy definitions */
  85.  
  86. #define Null(t) ((t)0)
  87. #define Nullch Null(char *)
  88. #define Nullfp Null(FILE *)
  89. #define Nulline Null(LINENUM)
  90.  
  91. #define Ctl(ch) ((ch) & 037)
  92.  
  93. #define strNE(s1,s2) (strcmp(s1, s2))
  94. #define strEQ(s1,s2) (!strcmp(s1, s2))
  95. #define strnNE(s1,s2,l) (strncmp(s1, s2, l))
  96. #define strnEQ(s1,s2,l) (!strncmp(s1, s2, l))
  97.  
  98. /* typedefs */
  99.  
  100. typedef char bool;
  101. typedef long LINENUM;            /* must be signed */
  102. typedef unsigned MEM;            /* what to feed malloc */
  103.  
  104. /* globals */
  105.  
  106. EXT int Argc;                /* guess */
  107. EXT char **Argv;
  108. EXT int Argc_last;            /* for restarting plan_b */
  109. EXT char **Argv_last;
  110.  
  111. EXT struct stat filestat;        /* file statistics area */
  112. EXT int filemode INIT(0644);
  113.  
  114. EXT char buf[MAXLINELEN];        /* general purpose buffer */
  115. EXT FILE *ofp INIT(Nullfp);        /* output file pointer */
  116. EXT FILE *rejfp INIT(Nullfp);        /* reject file pointer */
  117.  
  118. EXT int myuid;                /* cache getuid return value */
  119.  
  120. EXT bool using_plan_a INIT(TRUE);    /* try to keep everything in memory */
  121. EXT bool out_of_mem INIT(FALSE);    /* ran out of memory in plan a */
  122.  
  123. #define MAXFILEC 2
  124. EXT int filec INIT(0);            /* how many file arguments? */
  125. EXT char *filearg[MAXFILEC];
  126. EXT bool ok_to_create_file INIT(FALSE);
  127. EXT char *bestguess INIT(Nullch);    /* guess at correct filename */
  128.  
  129. EXT char *outname INIT(Nullch);
  130. EXT char rejname[128];
  131.  
  132. EXT char *origprae INIT(Nullch);
  133.  
  134. EXT char *TMPOUTNAME;
  135. EXT char *TMPINNAME;
  136. EXT char *TMPREJNAME;
  137. EXT char *TMPPATNAME;
  138. EXT bool toutkeep INIT(FALSE);
  139. EXT bool trejkeep INIT(FALSE);
  140.  
  141. EXT LINENUM last_offset INIT(0);
  142. #ifdef DEBUGGING
  143. EXT int debug INIT(0);
  144. #endif
  145. EXT LINENUM maxfuzz INIT(2);
  146. EXT bool force INIT(FALSE);
  147. EXT bool batch INIT(FALSE);
  148. EXT bool verbose INIT(TRUE);
  149. EXT bool reverse INIT(FALSE);
  150. EXT bool noreverse INIT(FALSE);
  151. EXT bool skip_rest_of_patch INIT(FALSE);
  152. EXT int strippath INIT(957);
  153. EXT bool canonicalize INIT(FALSE);
  154.  
  155. #define CONTEXT_DIFF 1
  156. #define NORMAL_DIFF 2
  157. #define ED_DIFF 3
  158. #define NEW_CONTEXT_DIFF 4
  159. #define UNI_DIFF 5
  160. EXT int diff_type INIT(0);
  161.  
  162. EXT bool do_defines INIT(FALSE);    /* patch using ifdef, ifndef, etc. */
  163. EXT char if_defined[128];        /* #ifdef xyzzy */
  164. EXT char not_defined[128];        /* #ifndef xyzzy */
  165. EXT char else_defined[] INIT("#else\n");/* #else */
  166. EXT char end_defined[128];        /* #endif xyzzy */
  167.  
  168. EXT char *revision INIT(Nullch);    /* prerequisite revision, if any */
  169.  
  170. #include <errno.h>
  171. #ifndef errno
  172. extern int errno;
  173. #endif
  174.  
  175. FILE *popen();
  176. char *malloc();
  177. char *realloc();
  178. long atol();
  179. char *getenv();
  180. char *strcpy();
  181. char *strcat();
  182. char *rindex();
  183. long lseek();
  184. char *mktemp();
  185. #if 0                /* This can cause a prototype conflict.  */
  186. #ifdef CHARSPRINTF
  187. char *sprintf();
  188. #else
  189. int sprintf();
  190. #endif
  191. #endif
  192.  
  193. #if !defined(S_ISDIR) && defined(S_IFDIR)
  194. #define    S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  195. #endif
  196. #if !defined(S_ISREG) && defined(S_IFREG)
  197. #define    S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  198. #endif
  199.